package priv.utrix.micro.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import priv.utrix.micro.dto.SecurityUserDto;
import priv.utrix.micro.json.R;
import priv.utrix.micro.utils.SecurityUtil;

/**
 * 获取当前登录用户
 *
 * @author utrix
 * @date 2020/11/28
 */
@Slf4j
@RestController
@RequestMapping("/current")
public class GetCurrentUserController {

    /**
     * 获取当前登录用户测试类
     * <p>请求头中必须带 Authorization， 对应值是: jti
     * 自定义的过滤器，会把jti解析成token</p>
     *
     * @return priv.utrix.micro.json.R<priv.utrix.micro.dto.SecurityUserDto>
     */
    @GetMapping
    public R<SecurityUserDto> get() {
        SecurityUserDto user = SecurityUtil.getUser();
        return R.ok(user);
    }

}
